package top.yangguangmc.smart_scheduling.pojo;

import org.jetbrains.annotations.NotNull;

import java.io.Serializable;
import java.util.Objects;

/**
 * 封装一个班次数据。其名称唯一且不为空。
 */
@SuppressWarnings("unused")
public class Shift implements Serializable, Comparable<Shift> {
    public static final Shift EMPTY = new Shift("/");
    private String name;

    /**
     * 构造一个班次对象，名字不可为空。
     * @param name  班次名
     */
    public Shift(@NotNull String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(@NotNull String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) return true;
        if (object == null || getClass() != object.getClass()) return false;
        Shift shift = (Shift) object;
        return Objects.equals(name, shift.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }

    @Override
    public String toString() {
        return name;
    }

    @Override
    public int compareTo(@NotNull Shift o) {
        return name.compareTo(o.getName());
    }
}
